import axios from "@/libs/api.request"

export const getRoleList = (data) => {
    return axios.request({
        url: "/user/role",
        params: data,
        method: "get"
    });
}

export const addRole = (data) => {
    return axios.request({
        url: "/user/role",
        data: data,
        method: "post"
    });
}

export const delRole = (roleId) => {
    return axios.request({
        url: "/user/role?roleId=" + roleId,
        // params: data,
        method: "delete"
    });
}

export const editRole = (data) => {
    return axios.request({
        url: "/user/role",
        data: data,
        method: "put"
    });
}


//获取当前用户分配的菜单
export const getUserAllocationMenu = (data) => {
    return axios.request({
        url: "/user/menu/role_menus",
        params: data,
        method: "get"
    });
}

//获取当前用户分配的权限
export const getUserAllocationPermission = (data) => {
    return axios.request({
        url: "/user/perm/role_perms",
        params: data,
        method: "get"
    });
}

//获取所有的菜单
export const getAllMenu = (data) => {
    return axios.request({
        url: "/user/menu",
        params: data,
        method: "get"
    });
}

//获取所有的权限
export const getAllPermission = (data) => {
    return axios.request({
        url: "/user/perm",
        params: data,
        method: "get"
    });
}

//权限解除
export const delPermission = (data) => {
    return axios.request({
        url: "/user/link/delete_role_perm_link",
        params: data,
        method: "GET"
    });
}

//菜单解除
export const delMenu = (data) => {
    return axios.request({
        url: "/user/link/delete_role_menu_link",
        params: data,
        method: "GET"
    });
}

//为角色分配菜单
export const allocationMenu = (data) => {
    return axios.request({
        url: "/user/link/for_role_add_menus",
        data: data,
        method: "post"
    });
}

//为角色分配权限
export const allocationPermission = (data) => {
    return axios.request({
        url: "/user/link/for_role_add_perms",
        data: data,
        method: "post"
    });
}



